<?php

namespace com\aristo\ingenieros\util;

include 'com/aristo/ingenieros/lib/excel/PHPExcel/IOFactory.php';

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

use \PHPExcel_IOFactory;
use com\aristo\ingenieros\util\constAccount;

/**
 * Description of Imprimir
 *
 * @author ARISTO INGENIEROS
 */
class Imprimir {

    //put your code here
    public static function imprimirReciboIngreso($recibo, $detalle) {
        $objPHPExcel = PHPExcel_IOFactory::load('./com/aristo/ingenieros/templates/recibodeingresomatricial.xlsx');

        //se ponen las variables a usar
        $numeracion = $recibo["numeracion"];
        $apaterno = strtoupper($recibo["apellido_paterno"]);
        $amaterno = strtoupper($recibo["apellido_materno"]);
        $nombres = strtoupper($recibo["nombres"]);
        $direccion = strtoupper(($recibo["direccion"] != "NULL") ? $recibo["direccion"] : ".");
        $fecha = $recibo["fecha"];

        //se escribe en las celdas
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D3", $apaterno . ' ' . $amaterno . ' ' . $nombres);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D4", $direccion);
        //$objPHPExcel->setActiveSheetIndex(0)->setCellValue("k6", " " . $numeracion);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("F22", gmdate("Y", strtotime($fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D22", gmdate("M", strtotime($fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B22", gmdate("d", strtotime($fecha)));

        $index = 9;
        foreach ($detalle as $valor) {
            $descripcion = $valor["descripcion"];
            $cantidad = $valor["cantidad"];
            $monto = $valor["valor_unitario"];

            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $index, $cantidad);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E" . $index, $descripcion);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("Q" . $index, $monto);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("U" . $index, ($monto * $cantidad));
            $index++;
        }
        while($index<19) {
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $index, ".");
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E" . $index, ".");
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("Q" . $index, ".");
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("U" . $index, ".");
            $index++;
        }

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: filename="recibo_ingreso_' . $numeracion . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter->save('php://output');
    }

    public static function imprimirOrdenCompra($orden, $detalle) {
        $objPHPExcel = PHPExcel_IOFactory::load('./com/aristo/ingenieros/templates/ordencompra.xlsx');

        //se ponen las variables a usar
        $numeracion = $orden["numeracion"];
        $apaterno = $orden["apaterno"];
        $amaterno = $orden["amaterno"];
        $nombres = $orden["nombres"];
        $direccion = ($orden["direccion"] != "NULL") ? $orden["direccion"] : "";
        $almacen = $orden["almacen"];
        $descripcion = $orden["descripcion"];
        $referencia = ($orden["referencia"] != "NULL") ? $orden["referencia"] : "";
        $razonsocial = $orden["razonsocial"];
        $ruc = $orden["ruc"];
        $fecha = $orden["fecha"];

        //se escribe en las celdas
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("I5", " " . $numeracion);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("T6", gmdate("Y", time($fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("R6", gmdate("M", time($fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("O6", gmdate("d", time($fecha)));
        if (strlen($razonsocial) > 0) {
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C8", $razonsocial);
        } else {
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C8", $apaterno . ' ' . $amaterno . ', ' . $nombres);
        }
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C9", $direccion);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("G10", $almacen);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D11", $descripcion);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D12", $referencia);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D13", 'IESP "DAVID SANCHEZ INFANTE"');

        $index = 19;
        foreach ($detalle as $valor) {
            $descripcion = $valor["descripcion"];
            $cantidad = $valor["cantidad"];
            $monto = $valor["valor_unitario"];

            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C" . $index, $cantidad);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E" . $index, $descripcion);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("M" . $index, $monto);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("R" . $index, ($monto * $cantidad));
            $index++;
        }

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: filename="orden_compra_' . $numeracion . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter->save('php://output');
    }

    public static function imprimirComprobantePago($comprobante, $monto) {
        $objPHPExcel = PHPExcel_IOFactory::load('./com/aristo/ingenieros/templates/comprobantedepago.xlsx');

        //se ponen las variables a usar
        $apaterno = $comprobante["apaterno"];
        $amaterno = $comprobante["amaterno"];
        $nombres = $comprobante["nombres"];
        $almacen = $comprobante["almacen"];
        $descripcion = $comprobante["descripcion"];
        $razonsocial = $comprobante["razonsocial"];
        //$ruc = $comprobante["ruc"];

        $comp_numeracion = $comprobante["comp_numeracion"];
        $comp_nrcheque = constAccount::getNULL($comprobante["comp_nrcheque"]);
        $comp_nrofactura = $comprobante["comp_nrofactura"];
        $comp_fecha = $comprobante["comp_fecha"];
        $comp_sector = constAccount::getNULL($comprobante["comp_sector"]);
        $comp_pliego = constAccount::getNULL($comprobante["comp_pliego"]);
        $comp_programa = constAccount::getNULL($comprobante["comp_programa"]);
        $comp_subprograma = constAccount::getNULL($comprobante["comp_subprograma"]);
        $comp_proyecto = constAccount::getNULL($comprobante["comp_proyecto"]);
        $comp_obra = constAccount::getNULL($comprobante["comp_obra"]);
        $comp_fuertefinan = constAccount::getNULL($comprobante["comp_fuertefinan"]);
        $comp_funcional = constAccount::getNULL($comprobante["comp_funcional"]);

        $concepto = "Importe que se gira a " . $apaterno . " " . $amaterno . " " . $nombres;
        $concepto.=" por " . $descripcion . " en " . $almacen . ", con aplicación al presupuesto actual del I.E.S.P. 'DAVID SÁNCHEZ INFANTE' ";
        if ($razonsocial != "NULL") {
            $concepto .=", representante de " . $razonsocial . " ";
        }
        if ($comp_nrcheque != "-") {
            $concepto .=", pagado con Cheque número " . $comp_nrcheque . " ";
        } else {
            $concepto .=", pagado con efectivo de Caja ";
        }
        if ($comp_nrofactura != "NULL") {
            $concepto .=", según Factura/Boleta número " . $comp_nrofactura . " ";
        }
        $concepto .=" contrato.";
        //se escribe en las celdas
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("J3", " " . $comp_numeracion);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("L3", gmdate("Y", time($comp_fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("M3", gmdate("M", time($comp_fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("N3", gmdate("d", time($comp_fecha)));
        if (strlen($razonsocial) > 0) {
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C7", $razonsocial);
        } else {
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C7", $apaterno . ' ' . $amaterno . ', ' . $nombres);
        }
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B12", $concepto);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B21", $comp_sector);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C21", $comp_pliego);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D21", $comp_programa);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E21", $comp_subprograma);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("F21", $comp_proyecto);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("G21", $comp_obra);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("H21", $comp_fuertefinan);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("I21", $comp_funcional);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B55", gmdate("Y", time($comp_fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B56", gmdate("M", time($comp_fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B57", gmdate("d", time($comp_fecha)));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C9", constAccount::MontoMonetarioEnLetras($monto));
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("N36", $monto);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("N38", $monto);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("N56", $comp_nrcheque);

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: filename="comprobante_pago_' . $comp_numeracion . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter->save('php://output');
    }

    public static function imprimirLibroDiario($tipanio, $tipmes, $movimientos) {
        $objPHPExcel = PHPExcel_IOFactory::load('./com/aristo/ingenieros/templates/librodiario.xlsx');

        $borders = array('borders' => array('allborders' => array('style' => \PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000'))));
        $styleAnulado = array('fill' => array('type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'F20A29')));

        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B2", "LIBRO DIARIO: " . constAccount::getMes($tipmes) . " - " . $tipanio);
        $index = 6;
        foreach ($movimientos as $mov) {
            $fecha = $mov["fecha"];
            $esAnulado = $mov["esAnulado"];
            $tipo = $mov["tipo"];
            $numeracion = $mov["numeracion"];
            $descripcion = $mov["desCuenta"];
            $monto = $mov["monto"];

            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $index, $fecha);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C" . $index, $tipo);
            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D" . $index, $descripcion);
            if ($tipo == "DEBITO" || ($tipo == "INGRESO" && $numeracion != "" && $numeracion != "NULL")) {
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E" . $index, $monto); //debe
            } else if ($tipo == "INGRESO" && ($numeracion == "" || $numeracion == "NULL")) {
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("F" . $index, $monto); //haber
            } else if ($tipo == "CREDITO" || ($tipo == "EGRESO" && $numeracion != "" && $numeracion != "NULL")) {
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("F" . $index, $monto); //haber
            } else if ($tipo == "CREDITO" || ($tipo == "EGRESO" && $numeracion == "" || $numeracion == "NULL")) {
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E" . $index, $monto); //debe
            }
            $objPHPExcel->setActiveSheetIndex(0)->getStyle("B" . $index . ':F' . $index)->applyFromArray($borders);
            if ($esAnulado == "SI") {
                $objPHPExcel->setActiveSheetIndex(0)->getStyle("B" . $index . ':F' . $index)->applyFromArray($styleAnulado);
            }
            $index++;
        }

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: filename="libro_diario_' . constAccount::getMes($tipmes) . '-' . $tipanio . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter->save('php://output');
    }

    public static function imprimirLibroCaja($tipanio, $tipmes, $movimientos) {
        $objPHPExcel = PHPExcel_IOFactory::load('./com/aristo/ingenieros/templates/librocaja.xlsx');

        $borders = array('borders' => array('allborders' => array('style' => \PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000'))));
        $styleAnulado = array('fill' => array('type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'F20A29')));

        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B2", "LIBRO CAJA: " . constAccount::getMes($tipmes) . " - " . $tipanio);
        $index = 6;
        foreach ($movimientos as $mov) {
            $fecha = $mov["fecha"];
            $esAnulado = $mov["esAnulado"];
            $tipo = $mov["tipo"];
            $numeracion = $mov["numeracion"];
            $descripcion = $mov["desCuenta"];
            $monto = $mov["monto"];

            if ($tipo != "CREDITO" && ($numeracion == "" || $numeracion == "NULL")) {
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $index, $fecha);
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C" . $index, $tipo);
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D" . $index, $descripcion);
                if ($tipo == "DEBITO" || $tipo == "INGRESO") {
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E" . $index, $monto); //debe
                } else if ($tipo == "EGRESO") {
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("F" . $index, $monto); //haber
                }
                $objPHPExcel->setActiveSheetIndex(0)->getStyle("B" . $index . ':F' . $index)->applyFromArray($borders);
                if ($esAnulado == "SI") {
                    $objPHPExcel->setActiveSheetIndex(0)->getStyle("B" . $index . ':F' . $index)->applyFromArray($styleAnulado);
                }
                $index++;
            }
        }

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: filename="libro_caja_' . constAccount::getMes($tipmes) . '-' . $tipanio . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter->save('php://output');
    }

    public static function imprimirLibroBanco($tipanio, $tipmes, $movimientos) {
        $objPHPExcel = PHPExcel_IOFactory::load('./com/aristo/ingenieros/templates/librobanco.xlsx');

        $borders = array('borders' => array('allborders' => array('style' => \PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000'))));
        $styleAnulado = array('fill' => array('type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'F20A29')));

        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B2", "LIBRO BANCO: " . constAccount::getMes($tipmes) . " - " . $tipanio);
        $index = 6;
        foreach ($movimientos as $mov) {
            $fecha = $mov["fecha"];
            $esAnulado = $mov["esAnulado"];
            $tipo = $mov["tipo"];
            $numeracion = $mov["numeracion"];
            $descripcion = $mov["desCuenta"];
            $monto = $mov["monto"];

            if ($tipo != "DEBITO" && $numeracion != "" && $numeracion != "NULL") {
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $index, $fecha);
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C" . $index, $tipo);
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D" . $index, $descripcion);
                if ($tipo == "INGRESO") {
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E" . $index, $monto); //debe
                } else if ($tipo == "CREDITO" || $tipo == "EGRESO") {
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("F" . $index, $monto); //haber
                }
                $objPHPExcel->setActiveSheetIndex(0)->getStyle("B" . $index . ':F' . $index)->applyFromArray($borders);
                if ($esAnulado == "SI") {
                    $objPHPExcel->setActiveSheetIndex(0)->getStyle("B" . $index . ':F' . $index)->applyFromArray($styleAnulado);
                }
                $index++;
            }
        }

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: filename="libro_banco_' . constAccount::getMes($tipmes) . '-' . $tipanio . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter->save('php://output');
    }

    public static function imprimirLibroMayor($tipanio, $tipmes, $cuentasmov) {
        $objPHPExcel = PHPExcel_IOFactory::load('./com/aristo/ingenieros/templates/libromayor.xlsx');

        $borders = array('borders' => array('allborders' => array('style' => \PHPExcel_Style_Border::BORDER_THIN, 'color' => array('argb' => 'FF000000'))));
        $styleAnulado = array('fill' => array('type' => \PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'F20A29')));

        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B2", "LIBRO MAYOR: " . constAccount::getMes($tipmes) . " - " . $tipanio);
        $index = 6;
        foreach ($cuentasmov as $cuenta) {
            $codigo = $cuenta["codigo"];
            $descripcion = $cuenta["descripcion"];

            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $index, $codigo . ' - ' . $descripcion);
            $objPHPExcel->setActiveSheetIndex(0)->getStyle("B" . $index . ':G' . $index)->applyFromArray($borders);
            $index++;
            foreach ($cuenta["value"] as $mov) {
                $mov_fecha = $mov["fecha"];
                $mov_esAnulado = $mov["esAnulado"];
                $mov_tipo = $mov["tipo"];
                $mov_numeracion = $mov["numeracion"];
                $mov_descripcion = $mov["desCuenta"];
                $mov_monto = $mov["monto"];

                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("C" . $index, $mov_fecha);
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D" . $index, $mov_tipo);
                $objPHPExcel->setActiveSheetIndex(0)->setCellValue("E" . $index, $mov_descripcion);
                if ($mov_tipo == "DEBITO" || ($mov_tipo == "INGRESO" && $mov_numeracion != "" && $mov_numeracion != "NULL")) {
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("F" . $index, $mov_monto); //debe
                } else if ($mov_tipo == "INGRESO" && ($mov_numeracion == "" || $mov_numeracion == "NULL")) {
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("G" . $index, $mov_monto); //haber
                } else if ($mov_tipo == "CREDITO" || ($mov_tipo == "EGRESO" && $mov_numeracion != "" && $mov_numeracion != "NULL")) {
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("G" . $index, $mov_monto); //haber
                } else if ($mov_tipo == "CREDITO" || ($mov_tipo == "EGRESO" && $mov_numeracion == "" || $mov_numeracion == "NULL")) {
                    $objPHPExcel->setActiveSheetIndex(0)->setCellValue("F" . $index, $mov_monto); //debe
                }
                $objPHPExcel->setActiveSheetIndex(0)->getStyle("C" . $index . ':G' . $index)->applyFromArray($borders);
                if ($mov_esAnulado == "SI") {
                    $objPHPExcel->setActiveSheetIndex(0)->getStyle("C" . $index . ':G' . $index)->applyFromArray($styleAnulado);
                }
                $index++;
            }

            $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B" . $index, '----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
            $index++;
        }

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: filename="libro_mayor_' . constAccount::getMes($tipmes) . '-' . $tipanio . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter->save('php://output');
    }

    public static function imprimirLibroBalanceGeneral($tipanio, $tipmes, $cuenta1101, $cuenta1201, $cuenta1202, $cuenta1205, $cuenta1301, $cuenta1507, $cuenta2101, $cuenta2103, $cuenta3101, $cuenta3201, $cuenta3401) {
        $objPHPExcel = PHPExcel_IOFactory::load('./com/aristo/ingenieros/templates/librobalancegeneral.xlsx');

        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("B2", "LIBRO BALANCE GENERAL: " . constAccount::getMes($tipmes) . " - " . $tipanio);

        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D8", $cuenta1101);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D9", $cuenta1201);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D10", $cuenta1202);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D11", $cuenta1205);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D12", $cuenta1301);

        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("D16", $cuenta1507);

        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("H8", $cuenta2101);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("H12", $cuenta2103);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("H18", $cuenta3101);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("H19", $cuenta3201);
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue("H20", $cuenta3401);

        $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
        header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        header('Content-Disposition: filename="libro_balance_general_' . constAccount::getMes($tipmes) . '-' . $tipanio . '.xlsx"');
        header('Cache-Control: max-age=0');
        $objWriter->save('php://output');
    }

}